<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/2
 * Time: 17:51
 */
require DXW_SMS_DIR."index.php";

use Qcloud\Sms\SmsSingleSender;
use Qcloud\Sms\SmsMultiSender;
use Qcloud\Sms\SmsVoiceVerifyCodeSender;
use Qcloud\Sms\SmsVoicePromptSender;
use Qcloud\Sms\SmsStatusPuller;
use Qcloud\Sms\SmsMobileStatusPuller;

use Qcloud\Sms\VoiceFileUploader;
use Qcloud\Sms\FileVoiceSender;
use Qcloud\Sms\TtsVoiceSender;
class Sms{
    private $appid;
    private $appkey;
    public function __construct(){
        $this->appid = DXW_SMS_APPID;
        $this->appkey = DXW_SMS_SEC;
    }

    static $_dis;
    public static function create(){
        if(null === self::$_dis){
            self::$_dis = new self;
        }
        return self::$_dis;
    }
    public function send($code,$phones,$tpl_id){
        try {
            $ssender = new SmsSingleSender($this->appid, $this->appkey);
            $expire_h = Conf::$vcode_expire_time/60;
            $param=[$code,$expire_h];
            $result = $ssender->sendWithParam("86", $phones,$tpl_id, $param, "","","");
            return json_decode($result,true);
        } catch(\Exception $e) {
            return [];
        }
    }

}